package com.tqz.dt.interceptors;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

/**
 * <p>事务拦截器对象
 *
 * @author tianqingzhao
 * @since 2021/7/7 16:00
 */
public class GlobalTransactionalInterceptor extends AbstractGlobalTransactionalInterceptor implements MethodInterceptor {

    @Override
    public Object invoke(final MethodInvocation invocation) throws Throwable {
        Class<?> targetClass = invocation.getThis().getClass();
        return invokeWithinTransaction(invocation.getMethod(), targetClass, new InvocationCallback() {

            @Override
            public Object proceedWithInvocation() throws Throwable {
                return invocation.proceed();
            }
        });
    }
}
